package com.iwhalecloud.citybrain.flow.platform.manager.infrastructure.repository;

import com.iwhalecloud.citybrain.flow.platform.manager.domain.model.task.FlowUserTaskRoleInfoVo;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.repository.FlowUserTaskRoleInfoRepository;
import com.iwhalecloud.citybrain.flow.platform.manager.infrastructure.entities.FlowUserTaskRoleInfo;
import com.iwhalecloud.citybrain.flow.platform.manager.infrastructure.mapper.FlowUserTaskRoleInfoDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: niechanggang
 * @date:2021/8/19 16:01
 * @description:
 */
@Service
public class FlowUserTaskRoleInfoRepositoryImpl  implements FlowUserTaskRoleInfoRepository {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private FlowUserTaskRoleInfoDAO  flowUserTaskRoleInfoDAO;

    @Override
    public int insertUserTaskRoleInfo(FlowUserTaskRoleInfoVo flowUserTaskRoleInfoVo) {
        FlowUserTaskRoleInfo flowUserTaskRoleInfo = new FlowUserTaskRoleInfo();
        BeanUtils.copyProperties(flowUserTaskRoleInfoVo, flowUserTaskRoleInfo);
        int num = flowUserTaskRoleInfoDAO.insertSelective(flowUserTaskRoleInfo);
        return num;
    }

    @Override
    public FlowUserTaskRoleInfoVo selectByDeployIdAndNodeCode(String deployId, String nodeCode) {
        FlowUserTaskRoleInfo  flowUserTaskRoleInfo = flowUserTaskRoleInfoDAO.selectByDeployIdAndNodeCode(deployId, nodeCode);
        if(flowUserTaskRoleInfo != null){
            FlowUserTaskRoleInfoVo  flowUserTaskRoleInfoVo = new FlowUserTaskRoleInfoVo();
            BeanUtils.copyProperties(flowUserTaskRoleInfo, flowUserTaskRoleInfoVo);
            return  flowUserTaskRoleInfoVo;
        }
        return null;
    }
}
